package com.work.straighttalk.presenter;

import android.app.Activity;

import com.work.straighttalk.bean.MyConversation;
import com.work.straighttalk.model.LoadBmobDataMImpl;
import com.work.straighttalk.model.i.LoadDataMI;
import com.work.straighttalk.presenter.i.LoadDataPresenterI;
import com.work.straighttalk.presenter.i.OnLoadFinishedListener;
import com.work.straighttalk.ui.i.BindDataVI;

import java.util.List;

/**
 * 先在数据库 查询 无 则去APP服务器查询 然后存入数据库 显示界面
 * 过程描述:
 * 获取全部会话的数据 更新界面 用用户名获取用户信息 获得头像信息 更新界面
 * Created by dllo on 16/3/5.
 */
public class ConversationLoadDataPImpl implements LoadDataPresenterI, OnLoadFinishedListener<List<MyConversation>> {
    private BindDataVI<List<MyConversation>> bindDataVI;
    private LoadDataMI loadDataMI;

    public ConversationLoadDataPImpl(BindDataVI<List<MyConversation>> bindDataVI) {
        this.bindDataVI = bindDataVI;
        loadDataMI = new LoadBmobDataMImpl();
    }


    /**
     * 下一步 应该存入数据库
     *
     * @param myConversations
     */
    @Override
    public void onLoadSuccess(List<MyConversation> myConversations) {
        bindDataVI.bindData(myConversations);
    }

    @Override
    public void onLoadError() {

    }

    @Override
    public void loadData(Object o) {
        loadDataMI.loadConversationData(this);
    }
}
